<?php /*Template Name:Guestbook*/;get_header();?>
<div style="display:none;"><?php if(!get_option('ini_bulletin') && get_option('ini_admin')){} else {include('includes/map.php');};?></div>
<div id="content">
<div class="main">
<?php if (have_posts()) :while (have_posts()) :the_post(); ?>
<div class="article">
<h2 class="title entry-title" property="v:title" style="text-align:center"><?php the_title();?></h2>
<div class="context" property="v:description">
<?php the_content(); ?>
</div>
<div class="clear" style="height:30px;"></div>
<div class="v_comment"><ul>
<?php
$query="SELECT COUNT(comment_ID) AS cnt, comment_author, comment_author_url, comment_author_email FROM (SELECT * FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->posts.ID=$wpdb->comments.comment_post_ID) WHERE comment_date > date_sub( NOW(), INTERVAL 3 MONTH ) AND user_id='0' AND comment_author_email != '' AND post_password='' AND comment_approved='1' AND comment_type='') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 60";
$wall = $wpdb->get_results($query);
foreach ($wall as $comment)
{
if( $comment->comment_author_url )
$url = $comment->comment_author_url;
else $url="#";
$r="rel='external nofollow'";
if (get_option('ini_avatar') == 'true') {
$tmp = "<a class='add-title' href='".$url."' ".$r." title='".$comment->comment_author." (已在本站点评".$comment->cnt."次)'><img src='".get_bloginfo('wpurl').'/avatar/'.md5(strtolower($comment->comment_author_email)).".jpg' alt=\"$comment->comment_author\" class='avatar' width='40' height='40'/></a>";}
else {
$tmp = "<a class='add-title' href='".$url."' ".$r." title='".$comment->comment_author." (已在本站点评".$comment->cnt."次)'>".get_avatar( $comment->comment_author_email, 40, get_bloginfo('template_directory'). '/images/avatar.jpg',$comment->comment_author )."</a>";}
$output .= $tmp;
}
echo $output ;?></ul></div>
<div class="clear"></div>
</div>
<div id="comments"><?php comments_template();?></div>
<?php endwhile; endif;?>
</div>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>